***Replication in Stata 17

cd "YOUR FILE PATH HERE"
use JEPS_replication.dta

***Figure 3
regress VotedFor2 i.candRace if Partisan==0 & RCV==0 
est store Plurality
regress VotedFor2 i.candRace if Partisan==0 & RCV==1 
est store RCV

***If do not already have coefplot installed in Stata, install using this command: ssc install coefplot, replace
coefplot (Plurality, label (Plurality Election) msymbol(triangle) base drop(_cons) xline(0, lwidth(medium) lp(dot) lc(black)) plotregion(color(white)) graphregion(color(white))) (RCV, label (RCV Election) msymbol(circle) base drop(_cons) plotregion(color(white)) graphregion(color(white)))

***In text: time to vote for mayor
sum pl_np_mayor_time_pagesubmit rcv_np_mayor_time_pagesubmit


***Figure 4 Left Panel
regress VotedFor2 i.candRace if Partisan==0 & ideo3==1
est store liberal
regress VotedFor2 i.candRace if Partisan==0 & ideo3==2
est store moderate
regress VotedFor2 i.candRace if Partisan==0 & ideo3==3
est store conservative

coefplot (liberal, label (Liberals) msymbol(triangle) base drop(_cons) xline(0, lwidth(medium) lp(dot) lc(black)) plotregion(color(white)) graphregion(color(white)) legend(row(1))) (moderate, label (Moderates) msymbol(circle) base drop(_cons)) (conservative, label (Conservatives) msymbol(square) base drop(_cons))

***Figure 4 Right Panel
regress VotedFor2 i.candRace if Partisan==0  & race2==0
est store white
regress VotedFor2 i.candRace if Partisan==0 & race2==1
est store black
regress VotedFor2 i.candRace if Partisan==0  & race2==2
est store asian
regress VotedFor2 i.candRace if Partisan==0 & race2==4
est store latino

coefplot (white, label (White Resp) msymbol(triangle) base drop(_cons) xline(0, lwidth(medium) lp(dot) lc(black)) plotregion(color(white)) graphregion(color(white)) legend(row(1))) (black, label (Black Resp) msymbol(circle) base drop(_cons)) (asian, label (Asian Resp) msymbol(square) base drop(_cons)) (latino, label (Latino Resp) msymbol(diamond) base drop(_cons))

****Figure 5
regress VotedFor2 i.candRace if Partisan==0 & RCV==1 
est store NonPart
regress VotedFor2 i.candRace if Partisan==1 & RCV==1 
est store Partisan

coefplot (NonPart, label (Non Partisan Election) msymbol(triangle) base drop(_cons) xline(0, lwidth(medium) lp(dot) lc(black)) plotregion(color(white)) graphregion(color(white))) (Partisan, label (Partisan Election) msymbol(circle) base drop(_cons) plotregion(color(white)) graphregion(color(white)))


***Figure 6 (see Excel workbook for figure)
 table  Rank candRace if atlarge==0 & Partisan==0 
 
 
 ***Appendix 

***Table A1 
 use JEPS_replication.dta, clear
 keep if election=="mayorC1"
 tab gender
 tab race2 latino
 tab pid7
 
***Table A3
 use JEPS_replication_2.dta, clear
 regress icandtxt i.candRace i.candGender
 
***Table A4
 table candRace, command(sem meanrtxt1 )
 table candGender, command(sem meanrtxt1 )

***Figure A1
use JEPS_replication.dta, clear
regress VotedFor2 i.candRace if Partisan==0 & RCV==0 
est store NonPart
regress VotedFor2 i.candRace if Partisan==1 & RCV==0 
est store Partisan

coefplot (NonPart, label (Non Partisan Election) msymbol(triangle) base drop(_cons) xline(0, lwidth(medium) lp(dot) lc(black)) plotregion(color(white)) graphregion(color(white))) (Partisan, label (Partisan Election) msymbol(circle) base drop(_cons) plotregion(color(white)) graphregion(color(white)))
